//
//  JWLookSecondCry.m
//  test
//
//  Created by 李彦宏 on 2018/3/5.
//  Copyright © 2018年 朱圳. All rights reserved.
//

#import "JWLookSecondCry.h"
#import "JWLookSDCtry.h"
#import "JStudCell.h"
#import "SDUserModel.h"
#import "JWUserManager.h"
@interface JWLookSecondCry ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) SDUserModel *model;
@end

@implementation JWLookSecondCry

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupTable];
}
//UItableView初始化
- (void)setupTable
{
    UITableView *tableView=[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    //隐藏组距导航栏的间距
    tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];
    tableView.backgroundColor=[UIColor whiteColor];
    tableView.showsHorizontalScrollIndicator=NO;
    tableView.showsVerticalScrollIndicator=NO;
    tableView.dataSource=self;
    tableView.delegate=self;
tableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
    [self.view addSubview:tableView];
    self.tableView=tableView;
}
#pragma -mark -----------------------------tableview datasource and delegate---------------------------------
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _SeDarry.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    JStudCell *cell=[JStudCell cellwithTableview:tableView];
    
    
    self.model=self.SeDarry[indexPath.row];
    
    cell.lb1.text=self.model.name;
    cell.lb2.text=self.model.college;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
        JWLookSDCtry *Stinfo=[[JWLookSDCtry alloc]init];
    
        self.model=self.SeDarry[indexPath.row];
    Stinfo.title=[NSString stringWithFormat:@"%@的信息",self.model.name];
        [JWUserManager saveSD:self.model];
    [self.navigationController pushViewController:Stinfo animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 1;
}


-(NSMutableArray *)SeDarry{
    if(!_SeDarry){
        _SeDarry=[[NSMutableArray alloc]init];
    }
    return _SeDarry;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
